package face.threaddemo;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * Created by zhangyanfei on 2019/6/26.
 *
 * @author zhangyanfei
 * @date 2019/06/26
 */
public class StorageWithBlockQueue {
    // 设定初始化大小
    private BlockingQueue<Object> blockingQueue = new LinkedBlockingQueue<>(10);

    public void put(Object object) throws InterruptedException {
        // 阻塞写
        blockingQueue.put(object);
    }

    public Object get() throws InterruptedException {
        // 阻塞读
        return blockingQueue.take();
    }
}
